package com.team.service.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * 缓存同步配置类
 */
@Configuration
@EnableAspectJAutoProxy
public class CacheSyncConfig {

    /**
     * 缓存同步交换机
     */
    @Bean
    public DirectExchange cacheSyncExchange() {
        return new DirectExchange("cache.sync.exchange", true, false);
    }

    /**
     * 缓存同步队列
     */
    @Bean
    public Queue cacheSyncQueue() {
        return new Queue("cache.sync", true);
    }

    /**
     * 绑定缓存同步队列到交换机
     */
    @Bean
    public Binding cacheSyncBinding() {
        return BindingBuilder.bind(cacheSyncQueue())
                .to(cacheSyncExchange())
                .with("cache.sync.key");
    }
} 